﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LIMS.Service;
using LIMS.Entities;
using Castle.Core.Logging;

namespace LIMS.Shared
{
    public class UserTypePermissionPresenter : BasePresenter<IUserTypePermissionManagementView>
    {
        private IUserTypePermissionManagementView view;
        private IUserTypePermissionService  permissionService;
        private ILogger logger;
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="view"></param>
        /// <param name="cService"></param>
        /// <param name="cUserService"></param>
        /// <param name="oLogger"></param>
        public UserTypePermissionPresenter(IUserTypePermissionManagementView view, 
                                        IUserTypePermissionService permissionService,
                                        
                                        ILogger oLogger)
            : base(view)
        {
            this.view = view;
            this.permissionService = permissionService;
            //this.userService = cUserService;
            this.logger = oLogger;
        }
        /// <summary>
        /// Initialize View for GroupManagementPresenter
        /// </summary>
        /// <returns></returns>
        public bool InitializeView()
        {
            try
            {
                logger.Info("Initializing user permission management view");
                //view.oGroupList = groupService.GetAllGroups();
                //view.oUsers = groupService.GetAllUsers();
                return true;
            }
            catch (Exception ex)
            {
                logger.Error("Error while initializing view. Error : " + ex.Message, ex);
                return false;
            }

        }


        /// <summary>
        /// Saves user type permission
        /// </summary>
        /// <param name="oGroup"></param>
        /// <returns></returns>
        public bool Save(UserTypePermission  ousertypepermission)
        {
            return permissionService.Save(ousertypepermission);
        }

        /// <summary>
        /// Deletes group
        /// </summary>
        /// <param name="oGroup"></param>
        /// <returns></returns>
        public bool Delete(UserTypePermission ousertypepermission)
        {
            // mark this group as deactive

            return permissionService.Delete(ousertypepermission);
        }
        /// <summary>
        /// Edit Group
        /// </summary>
        /// <param name="index"></param>
        public bool Edit(int index)
        {
            try
            {
               // view.CurrentIndex = index;
                return true;
            }
            catch (Exception ex)
            {
                logger.Error("Error occured while editing record. Exception : " + ex.Message, ex);
                return false;
            }
        }


    
    }
}
